package org.edu.service.impl.manage;

import java.sql.SQLException;

import org.edu.bean.TmBankinfo;
import org.edu.common.BaseDao;
import org.edu.service.manage.BankManageService;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Service;
@Service
public class BankManageServiceImpl extends BaseDao<TmBankinfo> implements BankManageService{

	public TmBankinfo findByAccount(final String account) {
		
		
		return (TmBankinfo)hibernateTemplate.execute(new HibernateCallback() {
			
			public Object doInHibernate(Session session) throws HibernateException,
					SQLException {
				return session.createQuery("FROM TmBankinfo o WHERE o.account=?")
				.setParameter(0,account)
				.uniqueResult();
			}
		});
		
	}

	public TmBankinfo findByTaxplayer(final String taxplayer) {
return (TmBankinfo)hibernateTemplate.execute(new HibernateCallback() {
			
			public Object doInHibernate(Session session) throws HibernateException,
					SQLException {
				return session.createQuery("FROM TmBankinfo o WHERE o.taxplayer=?")
				.setParameter(0,taxplayer)
				.uniqueResult();
			}
		});
	}

	public void update(TmBankinfo bankinfo) {
		hibernateTemplate.update(bankinfo);	
		hibernateTemplate.flush();
	}

	public void deleteBank(TmBankinfo bankinfo) {
		hibernateTemplate.delete(bankinfo);
	}


}
